<#assign ctx = request.contextPath />
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
   	<meta name="viewport" content="width=device-width, initial-scale=1 ,minimum-scale=1.0 ,maximum-scale=1.0" user-scalable=no>
    <title>个人中心</title>
    <link href="${ctx}/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link href="${ctx}/assets/css/weixing.css" rel="stylesheet" />
  </head>
  <body>
  	<div class="top">
  		<#if member?? && member.photo?? && (member.photo?length>0)>
  			<img src="${ctx}/upload/member/${member.photo}" class="img-circle center-block" style="width: 80px; height: 80px;">
  		<#else>
  			<img src="${ctx}/assets/img/a.png" class="img-circle center-block" style="width: 80px; height: 80px;">
  		</#if>
  		<h3 style=" margin-top: 5px;" id="memberName"><#if member??>${member.name?if_exists}</#if></h3>
  		<h3 style=" margin-top: 3px; font-size: 14px;" id="memberType"><#if member??>${member.type?if_exists}</#if></h3>
  		<div class="container-fluid">
		  <div id="yuee" class="row">
			   <div class="col-xs-6 text-left" id="memberMoney">余额:<#if member??>${member.virtual}</#if></div>
			   <div class="col-xs-6 text-right" id="memberCoupon">优惠券:${couponMoney!""}</div>
		  </div>
		</div>
  	</div>
  	<div class="container-fluid">
		  <div class="row">
		  	<div class="col-xs-6" style="border-right:1px solid #eee;">
		  		<div class="thumbnail">
		  			<a target="_blank" <#if member??>href='${ctx}/wx/v1/account?memberId=${member.id}'</#if>><img id="myimage" onmousedown="lighton()" onmouseup="lightoff()" src="${ctx}/assets/img/4-1.png" /></a>
		  			<div class="caption">
		  				<h2><a target="_blank" <#if member??>href='${ctx}/wx/v1/account?memberId=${member.id}'</#if>>我的账户</a></h2>
		  			</div>
		  		</div>
		  	</div>
		  	<div class="col-xs-6 ">
		  		<div class="thumbnail">
		  			<a target="_blank" <#if member??>href='${ctx}/wx/v1/coupon?memberId=${member.id}'</#if>><img src="${ctx}/assets/img/1-1.png" alt="优惠卷"></a>
		  			<div class="caption">
		  				<h2><a target="_blank" <#if member??>href='${ctx}/wx/v1/coupon?memberId=${member.id}'</#if>>我的优惠券</a></h2>
		  			</div>
		  		</div>
		  	</div>
		  </div>
		  <hr style=" margin-top: 0px; margin-bottom: 0px;"/>
		  <div class="row">
		  	<div class="col-xs-6 "style="border-right:1px solid #eee;">
		  		<div class="thumbnail">
		  			<a target="_blank" <#if telephone??>href='${ctx}/wx/v1/todayOrder2?phone=${telephone}'</#if>><img src="${ctx}/assets/img/2-2.png" alt="当前订单"></a>
		  			<div class="caption">
		  				<h2><a target="_blank" <#if telephone??>href='${ctx}/wx/v1/todayOrder2?phone=${telephone}'</#if>>当前订单</a></h2>
		  			</div>
		  		</div>
		  	</div>
		  	<div class="col-xs-6 ">
		  		<div class="thumbnail">
		  		
		  			<a target="_blank" <#if telephone??>href='${ctx}/wx/v1/historyOrder2?phone=${telephone}'</#if>><img src="${ctx}/assets/img/3-3.png" alt="历史订单"></a>
		  			<div class="caption">
		  				<h2><a target="_blank" <#if telephone??>href='${ctx}/wx/v1/historyOrder2?phone=${telephone}'</#if>>历史订单</a></h2>
		  			</div>
		  		</div>
		  	</div>
		  </div>
	</div>
	<div id="somediv">
	</div>
  </body>
</html>
<script type="text/javascript">
	window.daijia = {ctx:'${ctx}'};
</script>
<script src="${ctx}/assets/js/jquery-1.11.0.min.js"></script>
<script src="${ctx}/assets/js/bootstrap.min.js"></script>
<script src="${ctx}/assets/js/wxcommon.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	<#if member??>
		var memberType='${member.type?if_exists}';
		var telephone='${telephone?if_exists}';
		var membername='${member.name?if_exists}';
		
	 	if(memberType!='VIP用户'){
			$("#somediv").append("<h2 class='vip'>还不是VIP?<a id='applyImmediately' href='#'>立即申请</a></h2>");
			$("#applyImmediately").bind('click',function(){
				$.post('${ctx}/wx/v1/choosePag',{'phone':telephone,'name':membername},function(data){
					if(data.success){
						window.location.href='${ctx}/wx/v1/waiting';
					}else{
						window.location.href='${ctx}/wx/v1/askForVIP?phone='+telephone+'&membername='+membername;
					}
				});
			});
		}
	</#if>
	
	<#if !member??>
		if(em.is_weixin()){
			var base_url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=${setting.wxAppId?if_exists}&redirect_uri="+URLEncode('${setting.wxServer?if_exists}wx/v1/profile?phone=${phone?if_exists}')+"&response_type=code&scope=snsapi_base&state=null#wechat_redirect";
		
			var _obj = em.UrlGet();
		
			if(_obj.code){
				$.post('${ctx}/wx/v1/userInfo',{'code':_obj.code},function(data){
					if(data.success){
						var wxuser=data.object.openId;
						var phone=data.object.phone;
						window.location.replace("${ctx}/wx/v1/profile?phone="+phone+"");
					}
					else{
						if(data.object.error=="BINDNULL"){//未绑定
							window.location.replace('${ctx}/wx/v1/bind');
						}
						else if(data.object.error=="OPENIDNULL"){//未获取到openid
							window.location.replace(base_url);
						}
					}
				},'json');
			}
			else{
				window.location.replace(base_url);
			}
		}
		else{
			window.location.replace('${ctx}/wx/v1/bind');
		}
	</#if>
})	
</script>

